import { createSlice, PayloadAction } from '@reduxjs/toolkit';

// 定义状态的接口
interface ImageState {
  selectedImages: string[]; // 假设你选择的图像是字符串数组，可以根据需要调整类型
}

// 设置初始状态
const initialState: ImageState = {
  selectedImages: [],
};

// 创建 imageSlice
const imageSlice = createSlice({
  name: 'images',
  initialState,
  reducers: {
    addImage: (state, action: PayloadAction<string>) => {
      state.selectedImages.push(action.payload); // 添加图像
    },
  },
});

// 导出 actions 和 reducer
export const { addImage } = imageSlice.actions;
export default imageSlice.reducer;